<?php
/**
*作用: Q+接口 cpc专用
*说明: 
*版权: CPC
*作者: Red	QQ:316765128
*时间: 2011/10/12
**/
require_once 'qplus_open.php';

class cpc_qplus{
	var $qplus;

	function __construct(){
		global $Global;
		$this->qplus = new QPlusOpen($Global['qplus']['app_id'],$Global['qplus']['app_secret']);
	}
	function checkLogin($app_openid,$app_openkey){	//是否登录 true=>登录, false=>未登录
		$re = $this->qplus->checkLogin($app_openid,$app_openkey);/*{"ret":0,"valide":1} valide=>1 有效，0无效 {"ret":1} 返回错误*/
		$re = (array)$re;
		if(!empty($re) and $re['ret']=='0' and $re['valide']=='1'){
			Return true;
		}else{
			Return false;
		}
	}
	function getAvatar($app_openid,$app_openkey){	//获取头像
		$u = $this->qplus -> getUserInfo($app_openid,$app_openkey);
		$u = (array)$u;
		$re = '';
		if(!empty($u) and $u['ret']=='0'){
			$re = $u['info']['face'];
		}
		Return $re;
	}
	function getUserInfo($app_openid,$app_openkey){	//获取信息
		$u = $this->qplus -> getUserInfo($app_openid,$app_openkey);
		$u = (array)$u;
		$re = array();
		if(!empty($u) and $u['ret']=='0'){
			$u['info'] = (array)$u['info'];
			$re['nick'] = $u['info']['nick'];
			$re['gender'] = $u['info']['gender'];
			$re['face'] = $u['info']['face'];
		}
		Return $re;
	}
}
?>